package 反射2;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class TestBoss {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        //1.得到反射类对象
        Class<?> aClass = Class.forName("反射2.Boss");
        //2.创建类对象
        Object o = aClass.newInstance();
        //3.调用private中say方法
        Method say = aClass.getDeclaredMethod("Say", int.class, String.class, char.class);
        //4.关闭访问权限
        say.setAccessible(true);
        //5.反射调用方法 invoke
        Object invoke = say.invoke(o, 247, "蔡徐坤", '男');
        System.out.println("invoke = " + invoke);

    }
}